﻿ <!DOCTYPE html> 
 <html>
 <head>
     <?php if($_SESSION['sid']!=1) Header("Location: //www.12301.cc");?> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> 
     <script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
     <link rel="stylesheet" href="http://www.12301.cc/tpl/ui/common/ui_common.css"/> 
     <script type="text/javascript" src="http://www.12301.cc/js/echarts-2.2.1/build/dist/echarts-all.js"></script>
     <script language="javascript" src="/tpl/new_yl/monthly/js/index.js"></script>
     <link rel="stylesheet" href="/tpl/new_yl/monthly/css/style.css"/>
     <link rel="stylesheet" href="/tpl/new_yl/monthly/css/newChar.css"/>
     <title>票付通旅游营销平台</title>
 </head>
 <body>
     <div class="conWrap">
         <div class="titleBox">
             <span class="titleBox active" date="Box">销售报表</span>
             <span class="titleBox" date="wrap">平台运营月报</span>
         </div>
         <div class="Box">
             <div class="topNavBox">
                 <ul>
                     <li class="navList active" date="seven">最近7天</li>
                     <li class="navList" date="thirty">最近30天</li>
                     <li class="navList" date="quarter">上一季度</li>
                     <li class="navList" date="month">最近一年</li>
                 </ul>
                 <span class="timeDetail"></span>
                 <img class="payLoadImg" src="http://www.12301.cc/images/load.gif" /> 
             </div>
             <div class="charCon">
                 <div class="lt">
                     <span class="leadTxt">趋势分析</span>
                 </div>
                 <div class="leadNav">
                     <ul>
                         <li class="list active" date="order">订单数</li>
                         <li class="list" date="ticket">票数</li>
                         <li class="list" date="money">金额</li>
                     </ul>
                 </div>
                 <div id="sale" style="height:400px;"></div>
                 <input type="hidden" name="past" value="seven"> 
                 <input type="hidden" name="type" value="order"> 
                 <input type="hidden" name="chatype" value="chaorder"></div>
             <div class="charCon">
                 <div class="lt">
                     <span class="leadTxt">分销渠道分析</span>
                     <img class="paychaLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div class="leadNavs">
                         <ul>
                             <li class="list active" date="chaorder">订单数</li>
                             <li class="list" date="chamoney">金额</li>

                         </ul>
                     </div>
                     <div id="chart" style="height:400px;"></div>
                 </div>
                 <div class="rt">
                     <span class="leadTxt">
                         <span class="time">最近7天</span>
                         产品使用排行
                     </span>
                     <img class="timeLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div class="iChar">
                         <table class="tbProduct" border="0" cellpadding="0" cellspacing="0">
                             <thead>
                                 <tr>
                                     <th class="setAlign">产品名称</th>
                                     <th class="w60">
                                         订单数量
                                         <a class="sortBox" href="javascript:void(0)"></a>
                                     </th>
                                     <th class="w60">门票数</th>
                                     <th class="w80">总金额</th>
                                 </tr>
                             </thead>
                             <tbody class="tbody"></tbody>
                         </table>
                     </div>
                 </div>
             </div>
             <div class="charCon">
                 <div class="lt">
                     <span class="leadTxt">客源地分析</span>
                     <img class="mapLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div class="map" id="map" style="height:400px;"></div>
                 </div>
                 <div class="rt">
                     <span class="leadTxt">支付偏好</span>
                     <img class="paLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div class="pay" style="height:400px;"></div>
                 </div>
             </div>
             <div class="charCon">
                 <div class="lt">
                     <span class="leadTxt">活跃用户分析</span>
                     <img class="memberLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div id="active" style="height:400px;"></div>
                 </div>
                 <div class="rt">
                     <span class="leadTxt">运营费用分析</span>
                     <img class="platLoadImg" src="http://www.12301.cc/images/load.gif" /> 
                     <div id="plat" style="height:400px;"></div>
                 </div>
             </div>
         </div>
     </div>
     <div class="wrap" style="display:none;">
         <div class="topBox">
             <div class="selectBox"> <em class="selected">下单时间</em>
                 <div class="iconfont moreIcon">&#xe673;</div>
             </div>
             <!-- <span>VS</span>
         -->
         <span id="preYear" class="margin10">2014</span>

         <img class="loadImg" src="http://www.12301.cc/images/load.gif" style="display: none;"> 
         <ul class="listBox">
             <li class="list active" value="1">销售月报</li>
             <li class="list" value="2">签单月报</li>
             <li class="list" value="3">会员月报</li>
             <li class="list" value="4">产品月报</li>
         </ul>
         <div class="ui-page" style="position:relative;left:20px;top:-10px;">
             <ul class="dropBox"></ul>
         </div>
         <input type="hidden" name="yunying" value="false">
     </div>
     <div class="con">
         <div class="chartBox" >
             <ul class="countType w200">
                 <li class="list tType active" value="0">门票数</li>
                 <li class="list mType" value="1">金额</li>
             </ul>
             <ul class="countType w400" style="display: none">
                 <li class="list active" value="0">全部</li>
                 <li class="list" value="1">供应商</li>
                 <li class="list" value="2">分销商</li>
                 <li class="list" value="3">散客</li>
             </ul>
             <ul class="countType w600" style="display: none">
                 <li class="list active" value="0">全部</li>
                 <li class="list" value="1">景区</li>
                 <li class="list" value="2">演出/轮渡</li>
                 <li class="list" value="3">餐饮</li>
                 <li class="list" value="4">酒店</li>
                 <li class="list" value="5">线路</li>
             </ul>
         </div>
     </div>
     <div id="main" style="height:500px;padding:10px;"></div>
 </div>
 </div>

 </body>
 </html>
 <script type="text/javascript">

     var number_format = function(num) {
         var result = [ ], counter = 0;
         num = (num || 0).toString().split('');
         for (var i = num.length - 1; i >= 0; i--) {
             counter++;
             result.unshift(num[i]);
             if (!(counter % 3) && i != 0) { result.unshift(','); }
         }
         return result.join('');
     }

     var money_format = function(money) {
        if (money >= 10000) {
            money = (money / 10000).toFixed(1);
            money += '万';
        }
        return money += '元';
    }

     var loadData = function(past, type) {
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/sale_api.html",
             type : "POST",
             dataType : "json",
             data : {
                 past : past,
                 type : type
             },beforeSend:function()
             {
                 $(".payLoadImg").css("display","inline-block");
             },success:function(result) {
                 if (result.date.length <= 0) {
                     alert('此时间段内无数据返回');
                     return;
                 }
                 var myChart = echarts.init(document.getElementById('sale'));
                 var title = type == 'order' ? '单' : (type == 'ticket' ? '张' : '万元');

                 var option = {
                    title : {
                         text: '单位:' + title,
                         x   :20,
                         y   :30
                     },
                     legend: {                                   // 图例配置
                         padding: 5,                             // 图例内边距，单位px，默认上下左右内边距为5
                         itemGap: 5,                            // Legend各个item之间的间隔，横向布局时为水平间隔，纵向布局时为纵向间隔
                         data: ['当前', '同比'],
                     },
                     tooltip: {                                  // 气泡提示配置
                        trigger: 'axis',                     // 触发类型，默认数据触发，可选为：'axis'
                        formatter: function (params,ticket,callback) {
                            var res = '<br/>时间 : ' + params[0].name;
                            for (var i = 0, l = params.length; i < l; i++) {
                                res += '<br/>' + params[i].seriesName + ' : ' + number_format(params[i].value);
                            }
                            return res;
                        }
                    },
                     xAxis: [                                    // 直角坐标系中横轴数组
                         {
                             type: 'category',                   // 坐标轴类型，横轴默认为类目轴，数值轴则参考yAxis说明
                             data: result.date
                         }
                     ],
                     yAxis: [                                    // 直角坐标系中纵轴数组
                         {
                             type: 'value',                      // 坐标轴类型，纵轴默认为数值轴，类目轴则参考xAxis说明
                             boundaryGap: [0, 0],            // 坐标轴两端空白策略，数组内数值代表百分比
                             splitNumber: 8                     // 数值轴用，分割段数，默认为5
                         }
                     ],
                     series: [
                         {
                             name: '当前',                        // 系列名称
                             type: 'line',                       // 图表类型，折线图line、散点图scatter、柱状图bar、饼图pie、雷达图radar
                             data: result.cur,

                         },
                         {
                             name: '同比',
                             type: 'line',
                             data: result.tongbi,
                             itemStyle : {
                                 'normal' : {
                                     'lineStyle' : {
                                         'color' : '#62A3C3',
                                         'type' : 'dotted'
                                     }
                                 }
                             }
                         },
                         // {
                         //     name: '环比',
                         //     type: 'line',
                         //     data: result.huanbi,
                         //     itemStyle : {
                         //         'normal' : {
                         //             'lineStyle' : {
                         //                 'color' : '#D4AE67',
                         //                 'type' : 'dotted'
                         //             }
                         //         }
                         //     }
                         // },
                     ]
                 };
                 myChart.setOption(option);
                 myChart.setTheme('macarons');
                 $("#sale").append("<span style='position:relative;z-index:9999;left:150px;top:-560px;color:#A849A9;font-size:14px;'></span>")
                 $(".timeDetail").html("<strong>"+ result.date[0] + '~' + result.date[result.date.length - 1]+ "</strong>")
             },
             complete:function()
             {
                 $(".payLoadImg").fadeOut("slow");
             }
         })
     }
     var charChange = function(past, chatype){
         var xc='',tc='',lmm='',tn='',qne='',mt='',zgzx='',fx='',tb='',qt=''
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "json",
             data : {
                 action    : 5,
                 list      : chatype,
                 past      : past
             },beforeSend:function()
             {
                 $(".paychaLoadImg").css("display","inline-block");
             },
             success:function(res){
                 if(res.status=='failure') alert(res.msg)
                 for(var  i in res) {
                     if(i=="zgzx"){
                         if(chatype=="chamoney"){
                             zgzx=res[i]['s']/100
                         }else{
                             zgzx=res[i]['s']
                         }
                     }else if(i=="fx"){
                         if(chatype=="chamoney"){
                             fx=res[i]['s']/100
                         }else{
                             fx=res[i]['s']
                         }
                     }else  if(i==1214){
                         if(chatype=="chamoney"){
                             xc=res[i]['s']/100
                         }else{
                             xc=res[i]['s']
                         }
                     }else if(i==1454){
                         if(chatype=="chamoney"){
                             tc=res[i]['s']/100
                         }else{
                             tc=res[i]['s']
                         }
                     }else if(i==1472){
                         if(chatype=="chamoney"){
                             lmm=res[i]['s']/100
                         }else{
                             lmm=res[i]['s']
                         }
                     }else if(i==3034){
                         if(chatype=="chamoney"){
                             tn=res[i]['s']/100
                         }else{
                             tn=res[i]['s']
                         }
                     }else if(i==2175){
                         if(chatype=="chamoney"){
                             qne=res[i]['s']/100
                         }else{
                             qne=res[i]['s']
                         }
                     }else if(i==1853){
                         if(chatype=="chamoney"){
                             mt=res[i]['s']/100
                         } else{
                             mt=res[i]['s']
                         }
                     }else if(i==12301){
                         if(chatype=="chamoney"){
                             tb=res[i]['s']/100
                         }else{
                             tb=res[i]['s']
                         }
                     }else if(i=="qt"){
                         if(chatype=="chamoney"){
                             qt=res[i]['s']/100
                         }else{
                             qt=res[i]['s']
                         }
                     }
                     $(".setAbsolute .setFont_t").html(res['tnums']+0)
                     $(".setAbsolute .setFont_m").html(res['moneys']+0+'元')
                 }

                 option = {
                     tooltip : {
                         trigger: 'item',
                         formatter: "{a} <br/>{b} : {c} ({d}%)"
                     },
                     color:['#2EC7C9','#5AB1EF','#2EC7C9','#95706C','#D97A81','#BA4B12','#8D99B3','#FFB981','#97B552','#E5CF0C'],
                     legend: {
                         orient : 'vertical',
                         x : 'left',
                         data:['自供自销','OTA分销','携程网','同程网','驴妈妈','南京途牛旅游网','去哪儿','美团','淘宝码商','其他']
                     },
                     calculable : false,
                     series : [
                         {
                             name:'分销渠道',
                             type:'pie',
                             selectedMode: 'single',
                             radius : [0, 70],

                             x: '20%',
                             width: '40%',
                             funnelAlign: 'right',
                             max: 1548,
                             itemStyle : {
                                 normal : {
                                     label : {
                                         position : 'inner'
                                     },
                                     labelLine : {
                                         show : false
                                     }
                                 }
                             },
                             data:[
                                 {value:zgzx, name:'自供自销'},
                                 {value:fx, name:'OTA分销'},

                             ]
                         },
                         {
                             name:'分销渠道',
                             type:'pie',
                             radius : [100, 140],
                             x: '60%',
                             width: '35%',
                             funnelAlign: 'left',
                             max: 1048,

                             data:[
                                 {value:xc, name:'携程网'},
                                 {value:tc, name:'同程网'},
                                 {value:lmm, name:'驴妈妈'},
                                 {value:tn, name:'南京途牛旅游网'},
                                 {value:qne, name:'去哪儿'},
                                 {value:mt, name:'美团'},
                                 {value:tb, name:'淘宝码商'},
                                 {value:qt, name:'其他'},
                             ]
                         }
                     ]
                 };
                 var myChart = echarts.init(document.getElementById('chart'));
                 myChart.setOption(option);
             },complete:function() {
                 $(".paychaLoadImg").css("display","none");
             }
         })

     }
     var  payType =function (past){
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "json",
             data : {
                 action    : 6,
                 past      : past
             },beforeSend:function()
             {
                 $(".paLoadImg").css("display","inline-block");
             }, success:function(result) {
                 if(result.status=='failure')alert(result.msg)
                 var balances='',alipays='',credits='',pays='',wechats='',selfs='',unionpays='',rings=''
                 for(var i in result)
                 {
                     if(i=='wechats'){
                         wechats=result[i]/100
                     }else if(i=='balances'){
                         balances=result[i]/100
                     }else if(i=='alipays'){
                         alipays=result[i]/100
                     }else if(i=='credits'){
                         credits=result[i]/100
                     }else if(i=='pays'){
                         pays=result[i]/100
                     }else if(i=='rings'){
                         rings=result[i]/100
                     }else if(i=='selfs'){
                         selfs=result[i]/100
                     }else if(i=='unionpays'){
                         unionpays=result[i]/100
                     }
                 }
                 var option = {
                     tooltip : {
                         trigger: 'item',
                         formatter: "{a} <br/>{b} : {c} ({d}%)"
                     },
                     legend: {
                         orient : 'vertical',
                         x : 'left',
                         data:['支付宝支付','账户余额','授信支付','微信支付','现场支付','环讯支付','产品自销','银联支付']
                     },
                     tooltip: {                                  // 气泡提示配置
                        trigger: 'item',
                        position : function(old) {
                            console.log(old)
                            var newx = old[0] - 110;
                            var newy = old[1] - 20;
                            return [newx, newy]
                        },                     // 触发类型，默认数据触发，可选为：'axis'
                        formatter: function (params,ticket,callback) {
                            var res = params[1] + '<br/>金额:' + money_format(params[2]) + '<br/>占比:' + params[3] + '%';
                            console.log(params);
                            
                            return res;
                        }
                    },
                     calculable : false,
                     series : [
                         {
                             type:'pie',
                             radius : ['35%', '55%'],
                             itemStyle : {
                                 normal : {
                                     label : {
                                         show : false
                                     },
                                     labelLine : {
                                         show : false
                                     }
                                 },
                                 emphasis : {
                                     label : {
                                         show : true,
                                         position : 'center',
                                         textStyle : {
                                             fontSize : '30',
                                             fontWeight : 'bold'
                                         }
                                     }
                                 }
                             },
                             data:[
                                 {value:alipays, name:'支付宝支付'},
                                 {value:balances, name:'账户余额'},
                                 {value:credits, name:'授信支付'},
                                 {value:wechats, name:'微信支付'},
                                 {value:pays, name:'现场支付'},
                                 {value:rings, name:'环讯支付'},
                                 {value:selfs, name:'产品自销'},
                                 {value:unionpays, name:'银联支付'}
                             ]
                         }
                     ]
                 };
                 var myChart = echarts.init($('.pay')[0]);
                 myChart.setOption(option);
             },
             complete:function()
             {
                 $(".paLoadImg").fadeOut("slow");
             }
         })
     }
     var sortProduct =function(past){
         var time="最近7天"
         if(past=="thirty"){
             time="最近30天"
         }else if(past=="quarter"){
             time="上一季度"
         }if(past=="month"){
             time="最近一年"
         }
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "json",
             data : {
                 action    : 'hot',
                 past      : past
             },beforeSend:function()
             {
                 $(".timeLoadImg").css("display","inline-block");
             },success:function($res_html){
             $(".time").text(time);
             $(".tbody").html($res_html);
            }, complete:function()
             {
                 $(".timeLoadImg").fadeOut("slow");
             }
         })
     }
     var mapProdut =function(past){

         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "JSON",
             data : {
                 action  : 'map',
                 past    : past
             },beforeSend:function()
             {
                 $(".mapLoadImg").css("display","inline-block");
             },success:function(date){
                 var  len=date.length;
                 var  max=date[len-1].max
                 var option = {
                     title: {
                         text : 'china （点击切换）',
                         textStyle:{
                             fontSize: 12,
                             fontWeight: 'lighter',
                             color: '#AAAAAA'
                         }
                     },
                     tooltip : {
                         trigger: 'item',
                         formatter: '点击进入该省<br/>{b}'
                     },
                     dataRange: {
                         min: 0,
                         max: max,
                         color: ['orangered','yellow','lightskyblue'],
                         text:['高','低'],           // 文本，默认为数值文本
                         calculable : true
//                         x:'center',
//                         y:'top',
//                         orient:'horizontal'
                     },
                     series : [
                         {
                             type: 'map',
                             mapType: 'china',
                             selectedMode : 'single',
                             itemStyle:{
                                 normal:{label:{show:true}},
                                 emphasis:{label:{show:true}}
                             },
                             data:date
                         }]
                 };
                 var myChart = echarts.init(document.getElementById('map'));
                 var curIndx = 0;
                 var mapType = [
                     'china',
                     // 23个省
                     '广东', '青海', '四川', '海南', '陕西',
                     '甘肃', '云南', '湖南', '湖北', '黑龙江',
                     '贵州', '山东', '江西', '河南', '河北',
                     '山西', '安徽', '福建', '浙江', '江苏',
                     '吉林', '辽宁', '台湾',
                     // 5个自治区
                     '新疆', '广西', '宁夏', '内蒙古', '西藏',
                     // 4个直辖市
                     '北京', '天津', '上海', '重庆',
                     // 2个特别行政区
                     '香港', '澳门'
                 ];
                 myChart.on('mapSelected', function (param){
                     var len = mapType.length;
                     var mt = mapType[curIndx % len];
                     if (mt == 'china') {
                         // 全国选择时指定到选中的省份
                         var selected = param.selected;
                         for (var i in selected) {
                             if (selected[i]) {
                                 mt = i;
                                 while (len--) {
                                     if (mapType[len] == mt) {
                                         curIndx = len;
                                     }
                                 }
                                 break;
                             }
                         }
                         option.tooltip.formatter = '点击返回全国<br/>{b}';
                     }
                     else {
                         curIndx = 0;
                         mt = 'china';
                         option.tooltip.formatter = '点击进入该省<br/>{b}';
                     }
                     option.series[0].mapType = mt;
                     option.title.text = mt + ' （点击切换）';
                     myChart.setOption(option,true);
                 });
                 myChart.setOption(option);
             },
             complete:function()
             {
                 $(".mapLoadImg").fadeOut("slow");
             }
         })
     }
    var activeMember = function(past) {
        $.ajax({
            url : "http://www.12301.cc/module/pft_monthly/active_api.html",
            type : "POST",
            dataType : "json",
            data : {
                past : past
            },beforeSend:function()
            {
                $(".payLoadImg").css("display","inline-block");
            },success:function(result) {
                if (result.length <= 0) {
                    alert('此时间段内无数据返回');
                    return;
                }

                var myChart = echarts.init(document.getElementById('active'));

                var gongying = [], fenxiao = [], date = [], product = [];
                for (var index in result) {
                    gongying.push(result[index].a_count);
                    fenxiao.push(result[index].m_count);
                    date.push(result[index].date);
                    product.push(result[index].t_count);
                }
                
                var option = {
                    title : {
                         text: '单位:个',
                         x   :20,
                         y   :30
                     },
                    legend: {                                   // 图例配置
                        padding: 1,                             // 图例内边距，单位px，默认上下左右内边距为5
                        itemGap: 1,                             // Legend各个item之间的间隔，横向布局时为水平间隔，纵向布局时为纵向间隔
                        data: ['供应商', '分销商', '产品']
                    },
                    tooltip: {                                  // 气泡提示配置
                        trigger: 'item'                         // 触发类型，默认数据触发，可选为：'axis'
                    },
                    xAxis: [                                    // 直角坐标系中横轴数组
                        {
                            type: 'category', 
                            scale : true,
                            data: date,
                            splitNumber:7
                        }
                    ],
                    yAxis: [                                    // 直角坐标系中纵轴数组
                        {
                            type: 'value',                      // 坐标轴类型，纵轴默认为数值轴，类目轴则参考xAxis说明
                            boundaryGap: [0, 0],                // 坐标轴两端空白策略，数组内数值代表百分比
                            splitNumber: 8                      // 数值轴用，分割段数，默认为5
                        }
                    ],
                    series: [
                        {
                            name: '供应商',                        // 系列名称
                            type: 'line',                        // 图表类型，折线图line、散点图scatter、柱状图bar、饼图pie、雷达图radar
                            data: gongying
                        },
                        {
                            name: '分销商',                    
                            type: 'line',                       
                            data: fenxiao
                        },
                        {
                            name: '产品',                    
                            type: 'line',                       
                            data: product
                        }
                    ]
                };
                myChart.setOption(option);
                myChart.setTheme('macarons');
            },
            complete:function()
            {
                $(".memberLoadImg").fadeOut("slow");
            }
        })
    }
     var platType =function (past)
     {
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "json",
             data : {
                 action    : 7,
                 past       : past,
             },beforeSend:function()
             {
                 $(".platLoadImg").css("display","inline-block");
             }, success:function(result) {
                 if(result.status=='failure')alert(result.msg)
                 var eles='',mems=''
                 for(var i in result)
                 {
                     if(i=='7'){
                         eles=result[i]/100
                     }else if(i=='8'){
                         mems=result[i]/100
                     }
                 }
                 var option = {
                     tooltip : {
                         trigger: 'item',
                         formatter: "{a} <br/>{b} : {c} ({d}%)"
                     },
                     legend: {
                         orient : 'vertical',
                         x : 'left',
                         data:['平台使用费','电子凭证费','短信费']
                     },
                     tooltip: {                                  // 气泡提示配置
                        trigger: 'item',     
                        position : function(old) {
                            console.log(old)
                            var newx = old[0] - 110;
                            var newy = old[1] - 20;
                            return [newx, newy]
                        },               
                        formatter: function (params,ticket,callback) {
                            var res = params[1] + '<br/>金额:' + money_format(params[2]) + '<br/>占比:' + params[3] + '%';
                            return res;
                        }
                    },
                     calculable : false,
                     series : [
                         {
                             type:'pie',
                             radius : ['35%', '55%'],
                             itemStyle : {
                                 normal : {
                                     label : {
                                         show : false
                                     },
                                     labelLine : {
                                         show : false
                                     }
                                 },
                                 emphasis : {
                                     label : {
                                         show : true,
                                         position : 'center',
                                         textStyle : {
                                             fontSize : '30',
                                             fontWeight : 'bold'
                                         }
                                     }
                                 }
                             },
                             data:[
                                 {value:0, name:'平台使用费'},
                                 {value:eles, name:'电子凭证费'},
                                 {value:mems, name:'短信费'}
                             ]
                         }
                     ]
                 };
                 var myChart = echarts.init($('#plat')[0]);
                 myChart.setOption(option);
             },
             complete:function()
             {
                 $(".platLoadImg").fadeOut("slow");
             }
         })
     }
     var monthchangeType =function (action,time_af,time_pr,list)
     {
         var unit;
         time_p=time_pr.split(' ')
         time_vs=time_p[1]
         if(list==1 && action==1) {
             unit='单位：万元'
         }else if(list==0 && action==1) {
             unit='单位：张'
         }else if( action==2) {
             unit='单位：单'
         }else if( action==3) {
             unit='单位：位'
         }else if( action==4) {
             unit='单位：个'
         }
         $.ajax({
             url : "http://www.12301.cc/module/pft_monthly/monthly.html",
             type : "GET",
             dataType : "json",
             data : {
                 action    : action,
                 time_vs   : time_af,
                 time      : time_vs,
                 list      : list
             },beforeSend:function()
             {
                 $(".loadImg").css("display","inline-block");
             }, success:function(result) {
                 var time_mow=[],time_pre='',time_mow='',time_pre=[]
                 for(var i in result)
                 {
                     if(i+'年'==time_vs) {
                         time_pre=result[i]
                     }else {
                         time_mow=result[i]
                     }
                 }
                 if(time_vs==time_af) {
                     time_af = '无更早年份数据';
                 }
                 var option ={
                     title : {
                         text: unit,
                         x   :40,
                         y   :30
                     },
                     tooltip : {
//                        trigger: 'axis'
                     },
                     legend: {
                         data:[time_af,time_vs],
                         selected:{
                             '2014年' : true
                         }
                     },
                     toolbox: {
                         show : true,
                         feature : {
                             dataView : {show: true},
                             magicType : {show: true, type: ['line', 'bar']},
                             restore : {show: true},
                             saveAsImage : {show: true}
                         }
                     },
                     calculable : false,
                     xAxis : [
                         {
                             type : 'category',
                             data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
                         }
                     ],
                     yAxis : [
                         {
                             type : 'value',
                             splitArea : {show : true}
                         }
                     ],
                     series : [
                         {
                             name:time_af,
                             type:'bar',
                             data:time_mow
                         },
                         {
                             name:time_vs,
                             type:'bar',
                             data:time_pre
                         }
                     ]
                 };
                 var myChart = echarts.init($('#main')[0]);
                 myChart.setOption(option);
             },
             complete:function()
             {
                 $(".loadImg").fadeOut("slow");
             }
         })
     }
     Date.prototype.changeEvent = loadData;
//     $.post('http://www.12301.cc/module//wxh/monthly/monthly.html?action=hot&past=seven',function(res){
     $(function() {
         var action    = $.trim($(".topBox .active").val());
         var time_af   = $.trim($(".selectBox .selected").text());
         var time_pr   = $.trim($(".margin10").text());
         var list      = $.trim($(".chartBox .active").val());
         monthchangeType(action,time_af,time_pr,list);

         var past = $("input[name='past']").val();
         var type = $("input[name='type']").val();
         var chatype = $("input[name='chatype']").val();
         //初始化请求
         loadData(past, type);
         charChange(past, chatype);
         payType(past);
         sortProduct(past);
         mapProdut(past);
         activeMember(past);
         platType(past);
         $(".topNavBox li").on('click', function() {
             $(".topNavBox li").removeClass('active');
             var past = $(this).attr('date');
             $("input[name='past']").val(past);
             $(this).addClass('active');
             loadData(past, $("input[name='type']").val());
             charChange(past, chatype);
             payType(past);
             sortProduct(past);
             mapProdut(past);
             activeMember(past);
             platType(past);
         })

         $(".leadNav li").on('click', function() {
             $(".leadNav li").removeClass('active');
             var type = $(this).attr('date');
             $("input[name='type']").val(type);
             $(this).addClass('active');
             loadData($("input[name='past']").val(), type);
         })

         $(".leadNavs li").on('click', function() {
             $(".leadNavs li").removeClass('active');
             var chatype = $(this).attr('date');
             $("input[name='chatype']").val(chatype);
             $(this).addClass('active');
             charChange(past, $("input[name='chatype']").val());
         })

         $(".titleBox .titleBox").on('click', function() {
             $(".titleBox .titleBox").removeClass('active');
             $(this).addClass('active');
             var dat = $(this).attr('date');
            if(dat=="Box"){
                $('.Box').show();
                $('.wrap').hide();
            }else if(dat=="wrap"){
                $('.Box').hide();
                $('.wrap').show();
            }
            var flag = $("input[name='yunying']").val();
            if ( flag == 'false') {
                monthchangeType(action,time_af,time_pr,list);
                $("input[name='yunying']").val(true);
            }
         })
         //报表按钮
         $(".listBox").on('click','.list',function(e)
         {
             $(".listBox .active").removeClass("active");
             $(this).addClass("active");
             var action=$(this).val();
             $(".chartBox").show()
             $("#main").show()
             if(action==1) {
                 $(".w200").show()
                 $(".w400").hide()
                 $(".w600").hide()
             }else  if(action==2) {
                 $(".w200").hide()
                 $(".w400").hide()
                 $(".w600").hide()
             }else  if(action==3) {
                 $(".w400").show()
                 $(".w200").hide()
                 $(".w600").hide()
             }else if(action==4) {
                 $(".w200").hide()
                 $(".w400").hide()
                 $(".w600").show()
             }
             var time_af   = $.trim($(".selectBox .selected").text());//今年
             var time_pr   = $.trim($(".margin10").text());//去年
             if(action==1) {
                 var list      = $.trim($(".w200 .active").val());
             }else if(action==3) {
                 var list      = $.trim($(".w400 .active").val());
             }else if(action==4) {
                 var list      = $.trim($(".w600 .active").val());
             }
             monthchangeType(action,time_af,time_pr,list);
         })
         //日期改变后的动作
         $(".dropBox li").live("click",function(){
             var action    = $.trim($(".topBox .active").val());
             var time_af   = $.trim($(".selectBox .selected").text());
             var time_pr   = $.trim($(".margin10").text());
             if(action==1) {
                 var list      = $.trim($(".w200 .active").val());
             }else if(action==3) {
                 var list      = $.trim($(".w400 .active").val());
             }else if(action==4) {
                 var list      = $.trim($(".w600 .active").val());
             }
             monthchangeType(action,time_af,time_pr,list);
         })
         $(".countType .list").live('click',function(e) {
             $(this).siblings().removeClass("active");
             $(this).addClass("active");
             var list      = $(this).val();
             var action    = $.trim($(".topBox .active").val());
             var time_af   = $.trim($(".selectBox .selected").text());
             var time_pr   = $.trim($(".margin10").text());
             monthchangeType(action,time_af,time_pr,list);
         })
     })

 </script>